package com.rd.student.jike.class4.wanghaixin.Demo;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Scanner;

public class Player {
    public static void main(String[] args) throws Exception {
        Reader r = new FileReader("player.txt");
        BufferedReader br = new BufferedReader(r);
        ArrayList<String> arrays = new ArrayList<>();
        String team;
        while((team = br.readLine())!=null){
            arrays.add(team);
        }
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查询的球员名称:");
        String name = sc.next();
        for (int i = 0; i < arrays.size(); i++) {
            String ss = arrays.get(i);
            if(ss.contains(name)){
                int index = ss.indexOf('，');
                team = ss.substring(index);
                break;
            }
        }
        if(team == null){
            System.out.println("不存在该成员");
        }else{
            System.out.println("球员所在的队伍:" + team);
        }

    }
}
